#include <omp.h>
#include <stdio.h>
#include <stdlib.h>

double crono()
	{
		struct timeval tv;
		gettimeofday(&tv,0);
		return tv.tv_sec + tv.tv_usec/1e6;
	}


int main(int argc, char **argv)
	{
		int size = atoi(argv[1]);
		int i,j,r;
		float **m1,**m2,**mr;
		double start,end;

		start = crono();
		
		m1 = (float **)  malloc(sizeof(float*) * size);
		m2 = (float **) malloc(sizeof(float*) * size);
		mr = (float **) malloc(sizeof(float*) *size);
			
		for(i=0;i<size;i++)
			{
				m1[i] = malloc(sizeof(float) * size);
				m2[i] = malloc(sizeof(float) * size);
				mr[i] = malloc(sizeof(float) * size);
			}


		for(i=0;i<size;i++)
			for(j=0;j<size;j++)
				m1[i][j] = i;
			
		for(i=0;i<size;i++)	
			for(j=0;j<size;j++)
				m2[i][j] = j;
			
		for(i=0;i<size;i++)	
			for(j=0;j<size;j++)
				mr[i][j] = 0;

		#pragma omp parallel
		for(i=0;i<size;i++)
			for(j=0;j<size;j++)
				for(r=0;r<size;r++)
					mr[i][j] = m1[i][r] * m2[r][j];

		end = crono();

		printf("%f\n",end-start);
	return 0;
	}	
